#!/bin/bash
finalhtmlfile="mycrossx.html"

numberoftables=`cat $1 | grep -e \<table  -e \<TABLE | wc -l`
echo -e $numberoftables" HTML tables have been found."
if [ "$numberoftables" -ge 1 ]; then
    cat $1 | sed -rn '/\<TABLE/{:a;N;/TABLE>/{/.*/p;d};ba}' > table.prehtml
fi


echo "<HTML><BODY>" > "$finalhtmlfile"
cat table.prehtml >> "$finalhtmlfile"
echo "</BODY></HTML>" >> "$finalhtmlfile"
